/*
Copyright (c) 2010 Vadim Seregin
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/


#ifndef BASELIST_H
#define BASELIST_H

#include <wx/wx.h>
#include <wx/listctrl.h>
#include <wx/dir.h>
#include <SDL/SDL_mixer.h>
#include <list>

class BaseList : public wxEvtHandler
{

public:
	BaseList( wxListCtrl* pcListCtrl, wxString& soundFileDir );
	~BaseList();
	
	void SetToggle() { m_bToggle = 1 - m_bToggle; }
	
	// play sound file
	static void PlayFile( wxString& file );
	
	// get sound file
	static wxString GetFileName( wxString& path, wxString& wordId );
	
protected:
	// get number from the table anme
	long TableToLong( wxString& str, size_t startPos = 4 );
		
	// insert item in the list
	void InsertItem( wxString* pString, long end );
	
	// get text in the column
	wxString GetColumnText( long colIndex );
	wxString GetColumnText( long itemIdx, long colIndex );
	
	// get sound file
	wxString GetFileName( wxString& wordId );
	
	void CheckValidity( wxString& str );
	wxString GetValidString( wxString& str );
	
	// sorting event
	//virtual void OnSort( wxCommandEvent& event );

protected:	
	wxListCtrl*     m_pcListCtrl;    // ListCtrl
	wxString        m_sSoundDir;     // dir for sound files
	long            m_lItemIdx;      // word index in the list
	long            m_lItemNum;      // number of selected items in the list
	std::list<long> m_listSelectedItems; // list of selected items in the m_pcListCtrl
	
	bool            m_bToggle;       // true for switch over the Open function
};

#endif // BASELIST_H
